package com.antjupt.servlet;
/**
 * @author Wizarder
 * @create 2021-05-25 14:39
 */

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;

public class HelloServlet3 extends HttpServlet {
    @Override
    public void init(ServletConfig config) throws ServletException {
        System.out.println("2 init初始化");
        // 1、可以获取 Servlet程序的别名 servlet-name 的值
        String servletName = config.getServletName();
        System.out.println(servletName);
        // 2、获取初始化参数 init-param
        System.out.println(config.getInitParameter("username"));
        System.out.println(config.getInitParameter("url"));
        // 3、获取 ServletContext 对象
        ServletContext servletContext = config.getServletContext();
        System.out.println(servletContext);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("3 doGet请求");
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("3 doPost请求");
    }
}
